home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3120 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  945 b 

  1. Path: news.kth.se!news
  2. From: Anders Olsson <aolsson@ce.kth.se>
  3. Newsgroups: comp.lang.c++
  4. Subject: Vector of abstract classes using STL
  5. Date: Mon, 22 Jan 1996 11:40:26 +0100
  6. Organization: BKN, KTH
  7. Message-ID: <3103699A.79F8@ce.kth.se>
  8. NNTP-Posting-Host: zodiac.ce.kth.se
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b6a (X11; I; SunOS 5.4 sun4m)
  13.  
  14. I'm new to STL and have a question about vectors.
  15.  
  16. I have an abstract class Shape, that has pure virtual functions.
  17. From this class I derive rectangle and circle classes.
  18. I want to use a vector for storing the shapes.
  19.  
  20. I've tried using a vector<Shape>, but I get compiler errors because
  21. the Shape class cannot be instantiated. This must be the wrong way of
  22. doing it I understand.
  23.  
  24. I think I have to use a vector<Shape*> but does the vector delete
  25. the shape elements when the program finishes?
  26.  
  27. ---
  28. Anders Olsson
  29. Stockholm, Sweden
  30.